import vue from "@vitejs/plugin-vue";
import createSetupExtend from "./setup-extend.js";
import createAutoImport from "./auto-import";
import createCompression from "./compression";

import vueJsx from '@vitejs/plugin-vue-jsx'
import createExternalsPlugin from './external-plugin.js'
import createInsertHtml from './insert-html.js'
import createStaticCopy from './static-copy.js'
import cspPlugin from './csp.js'
import createSvgIcon from './svg-icon'

export default function createVitePlugins(viteEnv, isBuild = false ) {
    console.log('viteEnv', viteEnv )
    const vitePlugins  = [vue()];
    vitePlugins.push(createSetupExtend());
    vitePlugins.push(createAutoImport());
    // isBuild && vitePlugins.push(...createCompression(viteEnv))
    vitePlugins.push(createSvgIcon(isBuild))
    vitePlugins.push(vueJsx())
    // vitePlugins.push(cspPlugin(viteEnv))
    // vitePlugins.push(createExternalsPlugin())
    // 如果用在线库，需要配置成开发环境生效
    // !isBuild && vitePlugins.push(createStaticCopy(viteEnv))
    // vitePlugins.push(createInsertHtml(viteEnv, isBuild))
    isBuild && vitePlugins.push(...createCompression(viteEnv))

    return vitePlugins
}
